package com.hrbxlh.actionImpl;

import java.math.BigDecimal;
import java.util.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hrbxlh.dao.ClassDao;
import com.hrbxlh.dao.QuestionDao;
import com.hrbxlh.dao.RelationDao;
import com.hrbxlh.util.PubMethods;
import com.hrbxlh.util.pageUtil;
import com.hrbxlh.virtualization.dao.StatisticMapperExt;
import com.hrbxlh.vo.StuRankVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.hrbxlh.dao.MyCourseDao;
import com.hrbxlh.util.SessionValues;

/**
* -------------------------------------------------------
* Copyright (c) 2017, 鑫联华信息科技股份有限公司
* All rights reserved.
* FileName：MyCourseActionImpl.java
* Description：我的课程actionImpl类,负责查询登录人的课程信息。
* History：
* Date           Author               Desc
* 2017.4.5		  xzx                 建立
* -------------------------------------------------------
*/

@Component("myCourseActionImpl")
@Transactional
public class MyCourseActionImpl {

	@Resource(name="myCourseDao")
	private MyCourseDao myCourseDao;

	@Resource(name="courseActionImpl")
	private CourseActionImpl courseActionImpl;

	@Resource(name="classDao")
	private ClassDao classDao;

	@Resource(name="questionDao")
	private QuestionDao questionDao;

	@Resource(name="relationDao")
	private RelationDao relationDao;

	@Autowired
	private StatisticMapperExt statisticMapperExt;

	org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MyCourseActionImpl.class.getName());

	/**
	 * @description 获取登录人的课程信息，（学生、教师）
	 * @param Map<String,Object> paramMap  人员id，角色id
	 * @return List<Map<String,Object>>
	 * @throws Exception
	 */
	public List<Map<String, Object>> getMyCourse(Map<String, Object> paramMap) throws Exception{
		
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		try{
			//如果是学生
			if(Integer.parseInt(paramMap.get("roleId").toString()) == 1){
				list = myCourseDao.getStuCourse(paramMap);
			//如果是教师	
			}else if(Integer.parseInt(paramMap.get("roleId").toString()) == 2){
				list = myCourseDao.getTeacherCourse(paramMap);
			}
		}catch(Exception e){
			logger.error("获取登录人的课程信息异常getMyCourse", e);
			throw e; 
		}
		return list;
	}

	/**
	 * @description 教师课程管理列表分页
	 * */
	public Map<String, Object> getTeacherManaList(Map<String, Object> paramMap){
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//获取分页数据
		int pageNow = Integer.parseInt(paramMap.get("pageNow").toString());
		int pageSize = Integer.parseInt(paramMap.get("pageSize").toString());
		int startNum = 0;
		try {
			//需要列表形式的搜索
			paramMap.put("listMark", 1);
			startNum = pageUtil.getSqlStartPos(pageNow, pageSize);
			paramMap.put("startNum", startNum);
			//获取信息
			List<Map<String, Object>> courseList = myCourseDao.getTeacherCourse(paramMap);
			returnMap.put("courseList", courseList);
			returnMap.put("pageNow", pageNow);
			//获取全部页数
			paramMap.put("pageNow", 0);
			List<Map<String, Object>> allList = myCourseDao.getTeacherCourse(paramMap);
			int totalPage = pageUtil.getTotalPage(allList, pageSize);
			returnMap.put("totalPage", totalPage);
		} catch (Exception e) {
			logger.error("教师课程管理列表分页异常getTeacherManaList", e);
			e.printStackTrace();
		}
		return returnMap;
	}
	
	/**
	 * @description 获取课程表信息
	 * @param Map<String,Object> paramMap 工号
	 * @return List<Map<String, Object>>  课程表集合
	 * @throws Exception
	 */
	public List<Map<String, Object>> getCouseTab(Map<String, Object> paramMap) throws Exception{
		
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		try{
			//如果是学生
			if(Integer.parseInt(paramMap.get("roleId").toString()) == 1){
				list = myCourseDao.getStuCouseTab(paramMap);
			//如果是教师	
			}else if(Integer.parseInt(paramMap.get("roleId").toString()) == 2){
				//查询老师教的一种类型的课
				List<Map<String, Object>> oneList= myCourseDao.getTeaTeachCourseId(paramMap);
				if(oneList != null && oneList.size() != 0){
					paramMap.put("oneList", oneList);
					list = myCourseDao.getTeacherCouseTab(paramMap);
				}
				//查询老师教的正常课还有选课的课类型的
				paramMap.put("type", 3);
				List<Map<String, Object>> threeList= myCourseDao.getTeaTeachCourseId(paramMap);
				if(threeList != null && threeList.size() != 0){
					paramMap.put("threeList", threeList);
					List<Map<String, Object>> allTeachList = myCourseDao.getTeacherCouseTabAll(paramMap);
					if(allTeachList != null && allTeachList.size() != 0){
						if(list != null && list.size() != 0){
							list.addAll(allTeachList);
						}else{
							list = allTeachList;
						}
					}
				}
			}
		}catch(Exception e){
			logger.error("获取课程表信息异常getCouseTab", e);
			throw e; 
		}
		return list;
	}
	
	/**
	 * @description 获取课程表信息(上一周下一周的)
	 * @param Map<String,Object> paramMap 工号 角色
	 * @return List<Map<String, Object>>  课程表集合
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getTabList(Map<String, Object> paramMap) throws Exception{
		
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		try{
			List<String> listUse = (List<String>)paramMap.get("dateList");
			paramMap.put("startDate", listUse.get(0));
			paramMap.put("endDate", listUse.get(listUse.size()-1));
			//如果是学生
			if(Integer.parseInt(paramMap.get("roleId").toString()) == 1){
				list = myCourseDao.getStuCourseTabSearch(paramMap);
			//如果是教师	
			}else if(Integer.parseInt(paramMap.get("roleId").toString()) == 2){
				//查询老师教的一种类型的课
				List<Map<String, Object>> oneList= myCourseDao.getTeaTeachCourseId(paramMap);
				if(oneList != null && oneList.size() != 0){
					paramMap.put("oneList", oneList);
					list = myCourseDao.getTeacherCourseTabSearch(paramMap);
				}
				//查询老师教的正常课还有选课的课类型的
				paramMap.put("type", 3);
				List<Map<String, Object>> threeList= myCourseDao.getTeaTeachCourseId(paramMap);
				if(threeList != null && threeList.size() != 0){
					paramMap.put("threeList", threeList);
					List<Map<String, Object>> allTeachList = myCourseDao.getTeacherCourseTabSearchAll(paramMap);
					if(allTeachList != null && allTeachList.size() != 0){
						if(list != null && list.size() != 0){
							list.addAll(allTeachList);
						}else{
							list = allTeachList;
						}
					}
				}
			}
		}catch(Exception e){
			logger.error("获取课程表信息(上一周下一周的)异常getTabList", e);
			throw e; 
		}
		return list;
	}
	


	/**
	 * 20171101商莹
	 * @description 获取学生的课程及授课教师 type 1没有试卷 2有试卷  3有试卷且学生已经提交过试卷
	 * @param Map<String,Object> paramMap  人员id
	 * @return List<Map<String,Object>>
	 * @throws Exception
	 */
	public List<Map<String, Object>> getStuListCourse(Map<String, Object> paramMap) throws Exception{

		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> newList = new ArrayList<Map<String,Object>>();
		//orderBy为了排序---有试卷可以答题>有试卷答过题>没有试卷
		try{
			list = myCourseDao.getStuListCourse(paramMap);
			for (Map<String, Object> map:list) {
				Map<String,Object> newMap = new HashMap<String, Object>();
				if (Integer.parseInt(String.valueOf(map.get("onlinequestionId")))==0){
					//说明没有试卷
					newMap.put("type",1);
					newMap.put("orderBy","3");
				}if (Integer.parseInt(String.valueOf(map.get("onlinequestionId")))!=0){
					//说明有试卷,查询当前学生是否已经答过题
					paramMap.put("onlinequestionId",map.get("onlinequestionId"));
					Map<String,Object> stuquMap = questionDao.getStuAnswerByOnIdAndCouId(paramMap);
					//查询当前试卷信息
					//通过试卷主键id查询试卷文件名
					List<String> paramList = new ArrayList<String>();
					paramList.add(String.valueOf(map.get("onlinequestionId")));
					List<Map<String,Object>> questionList = questionDao.getAllFileNameListById(paramList);
					double mincha = PubMethods.surplusTimeTwo(String.valueOf(questionList.get(0).get("starttime")));
					double examtime = Double.valueOf(String.valueOf(questionList.get(0).get("examtime")));
					//延迟一分钟的时间
					double yctime = examtime+1;
					if(stuquMap!=null){
						if(stuquMap.size()!=0){
							//说明学生已经提交过试卷且有试卷
							newMap.put("type",3);
							newMap.put("orderBy","2");
						}if(stuquMap.size()==0&&(mincha<examtime)){
							//说明学生没有提交过试卷，但是有试卷,可以答题
							newMap.put("type",2);
							newMap.put("orderBy","1");
						}if(stuquMap.size()==0&&(mincha>=yctime)&&Integer.parseInt(String.valueOf(map.get("classExamState")))!=0
								&&Integer.parseInt(String.valueOf(map.get("examMark")))!=0&&Integer.parseInt(String.valueOf(map.get("rexamState")))!=0
								&&Integer.parseInt(String.valueOf(map.get("examState")))!=0){
							//说明考试时间已到，学生没有提交过试卷，但是有试卷,但是考这个试卷的时候学生没有在这个班里,所以当学生进入的时候不应该显示这个课的这个试卷
							continue;
						}if(stuquMap.size()==0&&(mincha>=examtime)&&mincha<yctime){
							//考试时间已过不可答题,考这个试卷的时候学生在这个班里
							newMap.put("type",3);
							newMap.put("orderBy","2");
						}
					}
					if(stuquMap==null&&(mincha>=examtime)&&mincha<yctime){
						//考试时间已过不可答题
						newMap.put("type",3);
						newMap.put("orderBy","2");
					}
					if(stuquMap==null&&(mincha<examtime)){
						//说明学生没有提交过试卷，但是有试卷,可以答题
						newMap.put("type",2);
						newMap.put("orderBy","1");
					}if(stuquMap==null&&(mincha>=yctime)&&Integer.parseInt(String.valueOf(map.get("classExamState")))!=0
							&&Integer.parseInt(String.valueOf(map.get("examMark")))!=0&&Integer.parseInt(String.valueOf(map.get("rexamState")))!=0
							&&Integer.parseInt(String.valueOf(map.get("examState")))!=0){
						//说明考试时间已到，学生没有提交过试卷，但是有试卷,但是考这个试卷的时候学生没有在这个班里,所以当学生进入的时候不应该显示这个课的这个试卷
						continue;
					}
				}
				newMap.put("courseColer",map.get("courseColer"));
				newMap.put("courseId",map.get("courseId"));
				newMap.put("courseName",map.get("courseName"));
				newMap.put("courseTitle",map.get("courseTitle"));
				newMap.put("examtime",map.get("examtime"));
				newMap.put("userName",map.get("userName"));
				newMap.put("examState",map.get("examState"));
				newList.add(newMap);
			}
			if(newList!=null&&newList.size()!=0){
				//通过orderBy排序
				Collections.sort(newList, new Comparator<Map<String, Object>>(){
					public int compare(Map<String, Object> o1, Map<String, Object> o2) {
						String name1 =(String)o1.get("orderBy");//name1是从你list里面拿出来的一个
						String name2= (String)o2.get("orderBy"); //name1是从你list里面拿出来的第二个name
						return name1.compareTo(name2);
					}
				});
			}
			logger.info("排序后的课程集合："+newList);
		}catch(Exception e){
			logger.error("获取学生的课程及授课教师异常getStuListCourse", e);
			throw e;
		}
		return newList;
	}

	/**
	 * 20171101商莹
	 * @description 获取学生的课程及授课教师(不与试卷关联)
	 * @param Map<String,Object> paramMap  人员id
	 * @return List<Map<String,Object>>
	 * @throws Exception
	 */
	public List<Map<String, Object>> getStuListAllCourse(Map<String, Object> paramMap) throws Exception{

		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		try{
			list = myCourseDao.getStuListAllCourse(paramMap);

		}catch(Exception e){
			logger.error("获取获取学生的课程及授课教师(不与试卷关联)getStuListAllCourse", e);
			throw e;
		}
		return list;
	}


	
	/**
	 * @description /获取这个学生这个课，这个章节的试验评价
	 * @param Map<String,Object> paramMap  课程id  章节id  登录人id  登录人角色
	 * @return List<Map<String,Object>>
	 * @throws Exception
	 */
	public Map<String, Object> getMyTestAssign(Map<String, Object> paramMap, HttpServletRequest request) throws Exception{
		
		Map<String, Object> map = new HashMap<String,Object>();
		try{	
			//获取登录人角色信息
			SessionValues session = new SessionValues();
			Map<String, Object> sessionValues = session.getSessionValues(new String[]{"roleId","stuorteaId"}, request, "userMsg");
			//如果是学生
			if(Integer.parseInt(sessionValues.get("roleId").toString()) == 1){
				paramMap.put("stuorteaId", sessionValues.get("stuorteaId"));
				//查询这个课，这个章节，这个学生的试验提交情况
				map = myCourseDao.getMyTestAssign(paramMap);
			}
		}catch(Exception e){
			logger.error("获取学生试验评价异常getMyTestAssign", e);
			throw e; 
		}
		return map;
	}

	/**
	 * @description 学生首页统计
	 * @return   1、实验总时长（需要自己累加）  2、回答问题总数answerNum  3、提问问题总数problemNum  4、完成作业总数homeworkNum  5、完成实验总数testNum
	 *           搜索条件：这个学生正在学习的课程信息，按照课程搜索：
	 *           搜索结果：1、课程的授课教师  userName
	 *                     2、这个课程本学生的得分
	 *                     3、排名
	 *                     4、这个课程的试验时长999
	             5、他学习的这个课程所在班级的全部学生的成绩信息（排名从高到低，如果有一个人有总成绩就按照总成绩排，如果没有就按照平时成绩排）
	 */
	public void stuMainCensus(String jsonStr, HttpServletRequest req, HttpServletResponse res) {
		Map<String, Object> map = new HashMap<String, Object>();
		ObjectMapper mapper = new ObjectMapper();
		try {
			if(jsonStr != null){
				map = mapper.readValue(jsonStr, map.getClass());
			}
			map.put("stuorteaId", new SessionValues().getSessionValues(new String[] {"stuorteaId"}, req, "userMsg").get("stuorteaId"));
			//获取这个学生的实验总时长  返回字段为：testTime
			map.put("testTime", statisticMapperExt.getExperimentDurationByStuorteaId(map.get("stuorteaId").toString()));
			//获取这个学生回答问题总数，提问问题总数，完成作业总数，完成实验总数，
			Map<String, Object> oneMsgMap = myCourseDao.getCountMsgStu(map);
			map.putAll(oneMsgMap);
			//如果有搜索条件
			if(map.get("courseId") != null && !map.get("courseId").toString().equals("")){
				//这个课这个学生的授课教师(班级id与教师姓名都在这个里面)
				Map<String, Object> classAndTeacherMap = myCourseDao.getMyTeacherNameById(map);
				map.put("userName", classAndTeacherMap.get("userName"));
				classAndTeacherMap.remove("stuorteaId");
				classAndTeacherMap.put("resultMark",1);
				//这个学生这个课所在这个班级的全部学生的成绩信息从高到低排名，如果有一个人有总成绩，就按照总成绩，如果都没有就按照平时成绩排
				List<StuRankVO> totalGradeListRank = myCourseDao.getTotalGradeRank(classAndTeacherMap);
				//如果总成绩不为空的集合不为空，用总成绩信息
				int mark = 0;
				if(totalGradeListRank != null && totalGradeListRank.size() != 0){
					classAndTeacherMap.put("resultMark",0);
					map.put("gradeList",myCourseDao.getTotalGradeRank(classAndTeacherMap));
					classAndTeacherMap.put("columnMark", "true");
					map.put("gradeListIds",myCourseDao.getTotalGradeRank(classAndTeacherMap));
				}else{
					mark = 1;
					//用平时成绩排名
					map.put("gradeList",myCourseDao.getNormalGradeRank(classAndTeacherMap));
					classAndTeacherMap.put("columnMark", "true");
					map.put("gradeListIds",myCourseDao.getNormalGradeRank(classAndTeacherMap));
				}
				//这个课这个学生的得分、这个学生这个课的排名
				classAndTeacherMap.put("stuorteaId", new SessionValues().getSessionValues(new String[] {"stuorteaId"}, req, "userMsg").get("stuorteaId"));
				if(mark == 0){
					classAndTeacherMap.put("resultMark",0);
					map.put("myRank", (myCourseDao.getTotalGradeRank(classAndTeacherMap) == null || myCourseDao.getTotalGradeRank(classAndTeacherMap).size() == 0) ? null :myCourseDao.getTotalGradeRank(classAndTeacherMap).get(0));
				}else if(mark == 1){
					map.put("myRank", (myCourseDao.getNormalGradeRank(classAndTeacherMap) == null || myCourseDao.getNormalGradeRank(classAndTeacherMap).size() == 0) ? null : myCourseDao.getNormalGradeRank(classAndTeacherMap).get(0));
				}
				//这个课程的实验时长   字段为：courseTestTime
				if(map.get("courseId") != null){
					map.put("courseTestTime", statisticMapperExt.getExperimentDurationByStuorteaIdAndCourseId(map.get("stuorteaId").toString(), Integer.parseInt(map.get("courseId").toString())));
				}
			}
			map.put("result", "success");
			courseActionImpl.responseStream(res, mapper.writeValueAsString(map));
		} catch (Exception e) {
			e.printStackTrace();
			map.put("result", "fail");
			map.put("failMsg", "查询失败");
			logger.error("学生首页统计异常stuMainCensus", e);
			try {
				courseActionImpl.responseStream(res, mapper.writeValueAsString(map));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}

	/**
	 * @description 获取学生正在学习的全部课程
	 * @param
	 * @return  response
	 *
	 */
	public void stuStudyCourses(HttpServletRequest req, HttpServletResponse res) {

		Map<String, Object> sessionMap = new HashMap<String, Object>();
		try {
			sessionMap = new SessionValues().getSessionValues(new String[] {"stuorteaId"}, req, "userMsg");
			List<Map<String, Object>> list = myCourseDao.getStuStudyCoursesNow(sessionMap);
			sessionMap.put("result", "success");
			sessionMap.put("list", list);
			courseActionImpl.responseStream(res, new ObjectMapper().writeValueAsString(sessionMap));
		} catch (Exception e) {
			e.printStackTrace();
			sessionMap.put("result", "fail");
			sessionMap.put("failMsg", "查询失败");
			logger.error("获取学生正在学习的全部课程异常stuStudyCourses", e);
			try {
				courseActionImpl.responseStream(res, new ObjectMapper().writeValueAsString(sessionMap));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}

	/**
	 * @description 教师首页统计
	 * @return  1、一共交过多少班级 2、一共交过多少人 3、批改试验报告数 4、批改作业数
	 *  搜索条件： 这个教师教的班级列表、 这个教师教的课程列表  ，状态 （1已结课0未结课）---默认搜索第一个班级第一个未结课的信息
	 * 	查询结果 ：1、班级学生人数
	 * 	          2、班级所属院系
	 * 	          3、所属专业
	 * 	          4、教学状态（已结课未结课）
	 * 	          5、班级类型（选课班正常班）
	              6、这个班级这个课考试及格率
	              7、这个班级这个课实验报告提交率
	              8、这个班级这个课作业提交率
	 */
	public void teacherMainCensus(String jsonStr, HttpServletRequest req, HttpServletResponse res) {
		Map<String, Object> map = new HashMap<String, Object>();
		ObjectMapper mapper = new ObjectMapper();
		try {
			if(jsonStr != null){
				map = mapper.readValue(jsonStr, map.getClass());
			}
			map.put("stuorteaId", new SessionValues().getSessionValues(new String[] {"stuorteaId"}, req, "userMsg").get("stuorteaId"));
			//一共教过多少班级 //一共教过多少人//批改实验报告数//批改作业数//搜索:某班级人数
			Map<String, Object> teacherTeachMsg = myCourseDao.getTeacherTeacCensus(map);
			map.putAll(teacherTeachMsg);
			//搜索：某班级院系，专业，状态（是否结课），类型(选课班正常班)
			if(map.get("classId") != null){
				Map<String, Object> classMap = classDao.getClassMsgById(map);
				Map<String, Object> classCheckMap = classDao.getClassNameById(map);
				//如果是选课班级，
				if(Integer.parseInt(classCheckMap.get("classMark").toString()) == 1){
					classMap = classCheckMap;
				}
				//查询是否结课的标识
				List<Map<String, Object>> endMarkList = relationDao.getRelCourseClass(map);
				if(endMarkList != null && endMarkList.size() != 0){
					classMap.put("useMark", endMarkList.get(0).get("classEndMark"));
				}
				map.putAll(classMap);
				//搜索：这个班级这个课考试及格率
				map.put("passPercent", getCoursePassPercent(map));
				//搜索：这个班级这个课实验报告提交率
				map.put("taskType", 2);
				map.put("submitTestPercent", getWorkPercent(map));
				//搜索：这个班级这个课作业提交率
				map.put("taskType", 1);
				map.put("submitHomeworkPercent", getWorkPercent(map));

			}
			map.put("result", "success");
			courseActionImpl.responseStream(res, mapper.writeValueAsString(map));
		} catch (Exception e) {
			e.printStackTrace();
			map.put("result", "fail");
			logger.error("教师首页统计异常teacherMainCensus", e);
			try {
				courseActionImpl.responseStream(res, mapper.writeValueAsString(map));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}

	/**
	 * @description 获取某个班级某个课程的学生的总成绩及格率
	 * @param 班级id   课程id 班级总人数
	 * */
	public BigDecimal getCoursePassPercent(Map<String, Object> paramMap){
		//如果总人数为空或者为0就返回0
		if(paramMap.get("stuTotalNum") == null || Integer.parseInt(paramMap.get("stuTotalNum").toString()) == 0){
			return BigDecimal.valueOf(0);
		}
		//查询通过的人数
		int passCount = myCourseDao.getPassDegreeCount(paramMap);
		if(passCount == 0){
			return BigDecimal.valueOf(0);
		}else{
			return new BigDecimal(passCount).divide(new BigDecimal(paramMap.get("stuTotalNum").toString()),2,BigDecimal.ROUND_DOWN);
		}
	}

	/**
	 * @description 获取某个班级某个课程的学生的实验报告或作业提交率
	 * @param classId ，
	 * @param courseId
	 * @param 班级总人数   stuTotalNum
	 * @param taskType:1作业还是2实验
	  */
	public BigDecimal getWorkPercent(Map<String, Object> paramMap){
		//如果总人数为空或者为0就返回0
		if(paramMap.get("stuTotalNum") == null || Integer.parseInt(paramMap.get("stuTotalNum").toString()) == 0){
			return BigDecimal.valueOf(0);
		}
		int submitCount = myCourseDao.getSubmitWorkCount(paramMap);
		if(submitCount == 0){
			return BigDecimal.valueOf(0);
		}else{
			return new BigDecimal(submitCount).divide(new BigDecimal(paramMap.get("stuTotalNum").toString()),2,BigDecimal.ROUND_DOWN);
		}
	}

	/**
	 * @description 查询某人某课的进度信息
	 * @param jsonStr stuorteaId   courseId
	 * */
	public void getMyProcess(String jsonStr, HttpServletResponse response){
		ObjectMapper mapper = new ObjectMapper();
		Map<String, Object> returnMap = new HashMap<String, Object>();
		try {
			returnMap = mapper.readValue(jsonStr, returnMap.getClass());
			returnMap = courseActionImpl.getMyStudyProcess(returnMap);
			returnMap.put("result", "success");
			courseActionImpl.responseStream(response, mapper.writeValueAsString(returnMap));
		} catch (Exception e) {
			returnMap.put("result", "fail");
			e.printStackTrace();
			logger.error("查询某人某课的进度异常getMyProcess", e);
			try {
				courseActionImpl.responseStream(response, mapper.writeValueAsString(returnMap));
			} catch (JsonProcessingException e1) {
				e1.printStackTrace();
			}
		}
	}
}